package com.uhu.code;

/**
 * 283. 移动零
 * https://leetcode.cn/problems/move-zeroes/description/?envType=study-plan-v2&envId=top-100-liked
 */
public class Solution283 {
    public void moveZeroes(int[] nums) {
        for(int i = 0; i <= nums.length - 1; i++) {
            if(nums[i] == 0) {
                int j = i + 1;
                while(j <= nums.length - 1 && nums[j] == 0) {
                    j++;
                }
                if(j <= nums.length - 1 && nums[j] != 0) {
                    int temp = nums[i];
                    nums[i] = nums[j];
                    nums[j] = temp;
                }
            }
        }
    }
}
